ZF.add('nodes', function(Z) {

    var D = Z.Dom,
        typeName = '_zfNodes';

    var NS = Z.Nodes = Z.create({

        // TODO: nodes is string, like :   '<p>111</p><p>222</p><p>33</p>'
        construct : function(nodes) {
            var self = this;

            if (nodes instanceof NS) {
                return nodes;
            } else {
                self._doms = Z.toArray(nodes);
            }

            return self;
        },
        
        getDom : function(index) {
            return this._doms[index || 0];
        },
        
        getDoms : function() {
            return this._doms;
        },
        
        size : function() {
            return this._doms.length;
        },
        
        each : function(fn, context) {
            var self = this, node, i = 0, l = self.size();
            for (node = self._doms[i]; i < l;) {
                fn.call(context || node, node, i, self);
                node = self._doms[++i];
            }
        },
        
        type : typeName

    }, null, { type : typeName });

    Z.extend(D, {

        all : function(selector, context) {
            return new NS(D.query(selector, context));
        }

    });

}, { requires : ['dom', 'dom-query'] });
